#ifndef BARISTA_DETAIL_IL_IMAGE_PLUGIN_HPP_INCLUDED
#define BARISTA_DETAIL_IL_IMAGE_PLUGIN_HPP_INCLUDED

/**
 * @file 
 */

#include <mocha/exported_image_plugin.hpp>

#include <IL/il.h>

namespace barista {
/// 
const char* const il_image_plugin_type_name = "barista_il_image_plugin";
/**
 * 
 */
class il_image_plugin : public mocha::graphics::exported_image_plugin<il_image_plugin> {
public:
	il_image_plugin(mocha_plugin_object_params* op);
	virtual ~il_image_plugin();
	virtual const mocha::plugin_char_t* type_name() const;
	virtual std::int32_t load(const boost::filesystem::path& file);
	virtual std::int32_t load(std::int8_t* buffer, std::uint32_t size);
	virtual std::int32_t load(std::int8_t* buffer, std::uint32_t width, std::uint32_t height, const mocha::graphics::pixel_format& format);
	virtual void free();
	virtual std::int32_t crop(const mocha::region<std::int32_t>& region);
	virtual std::int32_t scale(std::uint32_t width, std::uint32_t height);
	virtual std::int32_t convert(const mocha::graphics::pixel_format& format);
	virtual void pixels(std::int8_t*& buffer, std::uint32_t* size);
	virtual void pixels(std::int8_t const *& buffer, std::uint32_t* size) const;
	virtual std::int32_t format(mocha::graphics::pixel_format& format) const;
	virtual std::uint32_t width() const;
	virtual std::uint32_t height() const;
	virtual std::int8_t loaded() const;
	/**
	 * 
	 * @param other 
	 * @return 
	 */
	static void* clone(const void* other);
private:
	il_image_plugin(const il_image_plugin& other);
	void generate();
	void bind() const;
	mocha_plugin_object_params* op_;
	ILuint image_id_;
};
}

#endif

